import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '姓名',
    align:"center",
    dataIndex: 'userName_dictText'
  },
  {
    title: '所属单位',
    align:"center",
    dataIndex: 'orgcode_dictText'
  },
  {
    title: '证书名称',
    align:"center",
    dataIndex: 'certificateType_dictText'
  },
];

//列表数据
export const guardianHeadquarterscolumns: BasicColumn[] = [
  {
    title: '姓名',
    align:"center",
    dataIndex: 'userName_dictText'
  },
  {
    title: '证书名称',
    align:"center",
    dataIndex: 'certificateType_dictText'
  },
  {
    title: '证书编号',
    align:"center",
    dataIndex: 'orgcode'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "姓名",
    field: "userName",
    component: 'JSelectUserByDept',
    //colProps: {span: 6},
  },
  {
    label: "证书名称",
    field: "certificateType",
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"certificateType"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'userName',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey:'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入姓名!'},
      ];
     },
  },
  {
    label: '所属单位',
    field: 'orgcode',
    component: 'JSelectDept',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入所属单位!'},
      ];
     },
  },
  {
    label: '证书名称',
    field: 'certificateType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"certificateType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入证书名称!'},
      ];
     },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
	field: 'id',
	component: 'Input',
	show: false
  },
];

//子表列表数据
export const tbJobGuardianCertificateColumns: BasicColumn[] = [
  {
    title: '证书编号',
    align:"center",
    dataIndex: 'code'
  },
  {
    title: '证书名称',
    align:"center",
    dataIndex: 'certificateType_dictText'
  },
  {
    title: '发证机关',
    align:"center",
    dataIndex: 'issuingAuthority'
  },
  {
    title: '登记种类',
    align:"center",
    dataIndex: 'registrationType_dictText'
  },
  {
    title: '发证/复审/换证日期',
    align:"center",
    dataIndex: 'issueDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '下次复审/换证周期',
    align:"center",
    dataIndex: 'cycle'
  },
  {
    title: '下次复审/换证日期',
    align:"center",
    dataIndex: 'renewalDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
  },
  {
    title: '附件',
    align:"center",
    dataIndex: 'attachments',
  },
];
//子表表单数据
export const tbJobGuardianCertificateFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '证书编号',
    field: 'code',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入证书编号!'},
      ];
    },
  },
  {
    label: '证书名称',
    field: 'certificateType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"certificateType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入证书名称!'},
      ];
    },
  },
  {
    label: '发证机关',
    field: 'issuingAuthority',
    component: 'Input',
  },
  {
    label: '登记种类',
    field: 'registrationType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"registrationType"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入登记种类!'},
      ];
    },
  },
  {
    label: '发证/复审/换证日期',
    field: 'issueDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入发证/复审/换证日期!'},
      ];
    },
  },
  {
    label: '下次复审/换证周期',
    field: 'cycle',
    component: 'InputNumber',
  },
  {
    label: '下次复审/换证日期',
    field: 'renewalDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入下次复审/换证日期!'},
      ];
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '附件',
    field: 'attachments',
    component: 'JUpload',
    componentProps:{
     },
  },
];
//子表列表数据
export const tbJobGuardianWorktypeColumns: BasicColumn[] = [
  {
    title: '工种/资质',
    align:"center",
    dataIndex: 'jobTypeQualification_dictText'
  },
  {
    title: '证书编号',
    align:"center",
    dataIndex: 'code'
  },
  {
    title: '证书类型',
    align:"center",
    dataIndex: 'type_dictText'
  },
  {
    title: '有效期限',
    align:"center",
    dataIndex: 'validityPeriod',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
  },
  {
    title: '证件照片',
    align:"center",
    dataIndex: 'img',
    customRender:render.renderImage,
  },
];
//子表表单数据
export const tbJobGuardianWorktypeFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '工种/资质',
    field: 'jobTypeQualification',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"jobTypeQualification"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入工种/资质!'},
      ];
    },
  },
  {
    label: '证书编号',
    field: 'code',
    component: 'Input',
  },
  {
    label: '证书类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"C03"
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入证书类型!'},
      ];
    },
  },
  {
    label: '有效期限',
    field: 'validityPeriod',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入有效期限!'},
      ];
    },
  },
  {
    label: '证件照片',
    field: 'img',
     component: 'JImageUpload',
     componentProps:{
      },
  },
];

// 高级查询数据
export const superQuerySchema = {
  userName: {title: '姓名',order: 0,view: 'sel_user', type: 'string',},
  orgcode: {title: '所属单位',order: 1,view: 'sel_depart', type: 'string',},
  certificateType: {title: '证书名称',order: 2,view: 'list', type: 'string',dictCode: 'certificateType',},
};
